package com.xwaf.platform.system.provider.serviceimpl.hander;

import java.util.Iterator;

import org.springframework.stereotype.Service;

import com.xwaf.platform.system.api.entity.hander.TradeOrder;
import com.xwaf.platform.system.api.service.hander.TradeOrderHandler;
import com.xwaf.platform.system.api.service.hander.TradeOrderHandlerChain;

@Service("tradeOrderHandlerChainService")
public class TradeOrderHandlerChainServiceImpl implements TradeOrderHandlerChain {

	private Iterator<TradeOrderHandler> hanlderIterator;

	@Override
	public void setHanlders(Iterator<TradeOrderHandler> hanlderIterator) {
		this.hanlderIterator = hanlderIterator;
	}

	@Override
	public void doProcess(TradeOrder tradeOrder) {
		if (hanlderIterator != null && hanlderIterator.hasNext()) {
			TradeOrderHandler handler = hanlderIterator.next();
			handler.process(tradeOrder, this);
		}
	}

}
